<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        var arr = ['apple', 'banana', 'pear', 'apple', 'orange', 'orange'];

        // 利用filter
        let una = (arr) => {
            return arr.filter((item, index) => {
                // 找到星通的item并且要下标也一样才返回
                return arr.indexOf(item) === index;
            });
        };
        console.log(una(arr));
//  利用新数组 indexOf 查找 indexOf() 
    </script>
</body>

</html>